package com.link.base.base.interstatistics.service;

import com.link.base.base.interstatistics.model.ReportInfo;
import com.link.base.base.interstatistics.model.ReportParam;
import com.link.base.base.interstatistics.model.VisitInfo;
import com.link.base.base.interstatistics.model.VisitStatistics;
import com.link.core.basic.service.BasicService;
import com.link.core.util.redisclient.LinkRedisClient;


import java.util.List;
import java.util.Map;

/**
 * @author: 王艳
 * @date: 2018-12-13
 * @comments:
 */
public interface VisitInfoService extends BasicService<VisitInfo> {

    /**
     * 查询接口访问情况
     *
     * @param visitInfo
     * @return
     */
    public List<ReportInfo> queryReportOfInterfaceVisit(VisitInfo visitInfo);

    /**
     * 查询接口访问总数前十
     *
     * @return
     */
    public Map<String, List<ReportInfo>> queryReportOfTop10(ReportParam param);

    /**
     * 通过日期查询接口访问情况
     *
     * @return
     */
    public Map<String, int[]> queryReportByDate(String date);

    /**
     * 通过时间区间查询接口访问情况
     *
     * @return
     */
    public Map<String, Map<String, Integer>> queryReportByDateRange(long start, long end);

    /**
     * 通过缓存清空所有缓存数据
     *
     * @throws Exception
     */
    public void flushAllByCache(LinkRedisClient jedis) throws Exception;

    /**
     * 通过数据库清空所有缓存数据
     *
     * @throws Exception
     */
    public void flushAllByDb(LinkRedisClient jedis) throws Exception;

    /**
     * 将访问历史记录写入数据库
     *
     * @param list
     * @throws Exception
     */
    public void insertVisitStatistics(List<VisitStatistics> list) throws Exception;

    /**
     * 根据url清空访问记录缓存
     * @param visitInfo
     * @throws Exception
     */
    public void flushRecordInCache(VisitInfo visitInfo) throws Exception;
}
